//
//  YZMLockPassword.m
//  YZMicroStock
//
//  Created by Lv.Dongdong on 16/4/20.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZMLockPassword.h"

#define DEFAULT_FOR_LOCK_GESTURE_KEY  @"default_for_lock_gesture_key_"

@implementation YZMLockPassword

+ (NSString*)loadLockPassword
{
    if (!YZMUserServiceInstance.currentUser) {
        
        return nil;
    }
    
    NSUserDefaults* ud = [NSUserDefaults standardUserDefaults];
    NSString* pswd = [ud objectForKey:[DEFAULT_FOR_LOCK_GESTURE_KEY stringByAppendingString:YZMUserServiceInstance.currentUser.userID]];
    if (pswd != nil &&
        ![pswd isEqualToString:@""] &&
        ![pswd isEqualToString:@"(null)"]) {
        
        return pswd;
    }
    
    return nil;
}

+ (void)saveLockPassword:(NSString*)pswd
{
    [[NSUserDefaults standardUserDefaults] setObject:pswd forKey:[DEFAULT_FOR_LOCK_GESTURE_KEY stringByAppendingString:[YZMUserService sharedService].currentUser.userID]];
    [[NSUserDefaults standardUserDefaults] synchronize];
}


@end
